define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'trade/index' + location.search,
                    //add_url: 'order_list/add',
                    //edit_url: 'order_list/edit', 
                    //del_url: 'order_list/del',
                    //multi_url: 'order_list/multi',
                    table: 'trade_log',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('id')},
                        //{field: 'order_no', title: __('order_no')},
                        {field: 'brand.brand_name', title: __('会员')},
                        {field: 'before', title: __('交易前余额')},
                        {field: 'money', title: __('交易金额')},
                        {field: 'balance', title: __('交易后余额')},
                        {field: 'type', title: __('类型'),searchList:{"1":__('消费'),"2":__('充值')},formatter: Table.api.formatter.normal},
                        {field: 'add_time', title: __('时间'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                        {field: 'remarks', title: __('备注')},
                        /*{field: 'order_amount', title: __('订单金额')},
                        {field: 'price', title: __('面值')},
                        {field: 'price1', title: __('会员价')},
                        {field: 'retail_price', title: __('非会员价')},*/
                        //{field: 'retail_price', title: __('建议售价')},
                      /*  {field: 'order_no', title: __('Order_no')},*/
                      /*  {field: 'coupon_code_category_id', title: __('Coupon_code_category_id')},
                        {field: 'coupon_code_id', title: __('Coupon_code_id')},*/
                        /*{field: 'coupon_code', title: __('Coupon_code')},
                        {field: 'coupon_code_psd', title: __('Coupon_code_psd')},*/
                      /*  {field: 'status', title: __('Status')},*/
                        /*{field: 'pay_status', title: __('支付状态'),searchList:{"1":__('支付成功'),"0":__('支付失败'),"3":__('delete'),"4":__('background')},formatter: Table.api.formatter.normal},
                        {field: 'status', title: __('订单状态'),searchList:{"2":__('充值成功'),"1":__('充值失败'),"3":__('delete'),"4":__('background')},formatter: Table.api.formatter.normal},
                        {field: 'create_time', title: __('交易时间'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},*/
                        /*{field: 'end_time', title: __('完成时间'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},*/
                       
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});